python/xc: add missing Py_DECREF() to fix a memory leak
authorZhigang Wang <zhigang.x.wang@oracle.com>
Fri, 28 Aug 2015 21:35:18 +0000 (17:35 -0400)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 1 Sep 2015 11:05:19 +0000 (12:05 +0100)
commitd1ef21a5d1222c3b32d3d2314aafc16e948040f6
tree9517aec7471d82354046bc7b23b2e8064f662e6e
parentc011f470e6e79208f5baa071b4d072b78c88e2ba
python/xc: add missing Py_DECREF() to fix a memory leak

Python PyList_Append() will increase reference count of the item. We have to
decrease its reference count to let it garbage collected.

We missed the Py_DECREF() for 'cpuinfo_obj' here, thus we have a memory leak.

The memory leak could be easily confirmed by:

  # python
  >>> import xen.lowlevel.xc
  >>> xc = xen.lowlevel.xc.xc()
  >>> for i in range(1000): xc.getcpuinfo(1)

And check the python process memory usage before and after:

  # ps f -o vsize,rss,%mem,size,cmd -p <pid>

Signed-off-by: Zhigang Wang <zhigang.x.wang@oracle.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/python/xen/lowlevel/xc/xc.c